package com.tek.ding.faceding.presenter.face;


import com.tek.ding.faceding.base.BasePresenter;
import com.tek.ding.faceding.bean.BaseBean;
import com.tek.ding.faceding.network.rx.RxHttpResponseCompat;
import com.tek.ding.faceding.network.rx.observable.ProgressDialogObservable;

import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.schedulers.Schedulers;

public class FacePresenter extends BasePresenter<FaceContract.IFaceModel, FaceContract.FaceView> {

    public FacePresenter(FaceContract.IFaceModel model, FaceContract.FaceView view) {
        super(model, view);
    }

    public void getMemberList2(String storeUid, String namePhone) {
//        model.getMemberList2(storeUid, namePhone)
//                .compose(RxHttpResponseCompat.compatResult())
//                .subscribe(new ProgressDialogObservable<BaseBean<List<Members>>>(context, view) {
//                    //不显示提示框
//                    @Override
//                    protected boolean isShowDialog() {
//                        return true;
//                    }
//
//                    @Override
//                    public void onNext(@NonNull BaseBean<List<Members>> baseBean) {
//                        if (baseBean != null) {
//                            view.onLoadOk(baseBean);
//                        }
//                    }
//                });
        model.getMemberList2(storeUid, namePhone)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(bean -> {
                    if (bean != null) {
                        view.onLoadOk(bean);
                    }
                }, throwable -> {

                });
    }

    public void deleteFaceEntity2(String storeUid, String memberUid) {
        model.deleteFaceEntity2(storeUid, memberUid)
                .compose(RxHttpResponseCompat.compatResult())
                .subscribe(new ProgressDialogObservable<BaseBean<String>>(context, view) {
                    //不显示提示框
                    @Override
                    protected boolean isShowDialog() {
                        return true;
                    }

                    @Override
                    public void onNext(@NonNull BaseBean<String> baseBean) {
                        if (baseBean != null) {
                            view.onDelOk(baseBean);
                        }
                    }
                });
    }

}
